package com.cg.user_token.controller;

import com.cg.user_token.entity.User;
import com.cg.user_token.utils.JwtsUtils_01;
import com.cg.user_token.utils.JwtsUtils_02;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {

    @PostMapping("/login")
    public Map<String,Object> login(@RequestBody User user) throws UnsupportedEncodingException {

        HashMap<String,Object> maps = new HashMap<>();
        maps.put("user",user);
        maps.put("accessToken", JwtsUtils_02.getToken(user));
//        maps.put("accessToken", JwtsUtils.generateToken(user.getId()));
        return maps;
    }

    @GetMapping("/getMessage")
    public Map<String,Object> getMessage(){

        System.out.println(JwtsUtils_02.getTokenUserId());

        return null;
    }

}
